package com.longsunhd.yum.buffalo.base;

import android.app.Activity;

import com.longsunhd.yum.buffalo.activity.LoginActivity;
import com.longsunhd.yum.buffalo.activity.MainActivity;
import com.longsunhd.yum.buffalo.bean.LoginBean;
import com.longsunhd.yum.buffalo.constant.Constant;
import com.longsunhd.yum.buffalo.util.ActivitySkipUtil;
import com.longsunhd.yum.buffalo.util.ToastUtils;

import cc.fussen.cache.Cache;

/**
 * 作者：黄宣淇
 * 时间：2021/5/10 0010
 * 如何代码没有备注，一个月后，只有你和上帝知道--鲁迅
 */
public class GetTokenUtil {
    public static String getToken(Activity activity){
        LoginBean loginBean = Cache.with(activity).getCache(Constant.UserInfoBean, LoginBean.class);
        if(loginBean==null){
            ToastUtils.showText("没有获取用户授权信息");
            ActivitySkipUtil.skipAnotherActivity(activity, LoginActivity.class,true);
            return "";
        }
        return loginBean.getData().getToken_type() + " " + loginBean.getData().getAccess_token();
    }
}
